<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>3.几个常见的错误</title>
        <!-- 引入Vue -->
        <script type="text/javascript" src="../../js/vue.js"></script>
    </head>
    <body>
        <!-- 准备好一个容器-->
        <div id="demo"></div>

        <script type="text/javascript">
            // 第一步，创建（定义）组件
            const Person = Vue.extend({
                name:'Person',
                template:`
                    <div>
                        <h2>人员信息</h2>
                        <h4>姓名：{{pname}}</h4>
                        <h4>年龄：{{age}}</h4>
                        <button @click="showPersonInfo">点我提示人员的信息</button>
                    </div>
                `,
                data(){
                    return {
                        pname:'圆圆的海峰',
                        age:18,
                       
                    }
                },
                methods:{
                    showPersonInfo(){
                        alert(this.pname + '-' + this.age)
                    }
                }
            })
            const School = Vue.extend({
                template:`
                    <div>
                        <h2>学校信息</h2>
                        <h4>校名：{{sname}}</h4>
                        <h4>校址：{{address}}</h4>
                        <button @click="showSchoolInfo">点我提示学校的信息</button>
                    </div>
                `,
                data() {
                    return {
                        sname:'尚硅谷',
                        address:'宏福科技园'
                    }
                },
                methods:{
                    showSchoolInfo(){
                        alert(this.sname + '-' + this.address)
                    }
                }
            })
            
            new Vue({
                el:'#demo',
                template:`
                    <div>
                        <Person/>
                        <hr>
                        <AtguiguSchool/>  
                    </div>
                `,
                // 第二步：注册组件
                components:{
                    Person,
                    AtguiguSchool:School
                },
            })
            
            
        </script>
    </body>
</html>